/**
 * @file articleStore
 * @author wangshaozhi(wangshaozhi@baidu.com)
 */

import {action, makeObservable, observable} from 'mobx';
import Article from '../model/article';

export class ArticleStore {
    /** 文章列表 */
    articleList: Article[] = [].map(item => new Article(item));

    /** 当前操作的文章 */
    currOperateArticle: Article = new Article({
        publishTime: new Date().toLocaleDateString()
    });

    constructor() {
        makeObservable(this, {
            articleList: observable.shallow,
            currOperateArticle: observable
        });
    };

    update = action((data: Partial<ArticleStore>) => {
        Object.assign(this, data);
    });
}